package com.example.qiao.mvp.presenter;

import com.example.mylibrary.mvp.presenter.BasePresenter;
import com.example.qiao.bean.GUAN;
import com.example.qiao.bean.Tong;
import com.example.qiao.bean.Zhong;
import com.example.qiao.mvp.contract.PostContract;

import org.json.JSONException;

import java.util.List;

import io.reactivex.Observer;
import io.reactivex.disposables.Disposable;

public class PostPresenter extends BasePresenter<PostContract.Model, PostContract.View>{
    public PostPresenter(PostContract.Model mModel, PostContract.View mView) {
        super(mModel, mView);
    }

    public void initTong(){
        mModel.requestTong(new Observer<List<Tong>>() {
            @Override
            public void onSubscribe(Disposable d) {

            }

            @Override
            public void onNext(List<Tong> list) {
                mView.initTong(list);
            }

            @Override
            public void onError(Throwable e) {

            }

            @Override
            public void onComplete() {

            }
        });
    }

    public void initZhong(){
        mModel.requestZhong(new Observer<List<Zhong>>() {
            @Override
            public void onSubscribe(Disposable d) {

            }

            @Override
            public void onNext(List<Zhong> zhongs) {
                mView.initZHong(zhongs);
            }

            @Override
            public void onError(Throwable e) {

            }

            @Override
            public void onComplete() {

            }
        });
    }

    public void initGuan() throws JSONException {
        mModel.requestGuan(new Observer<List<GUAN>>() {
            @Override
            public void onSubscribe(Disposable d) {

            }

            @Override
            public void onNext(List<GUAN> list) {
                mView.initGuan(list);
            }

            @Override
            public void onError(Throwable e) {

            }

            @Override
            public void onComplete() {

            }
        });
    }
}
